package com.qqtech.qquan.order.dao;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;

import com.qqtech.core.common.util.BeanUtil;
import com.qqtech.core.frame.dao.BaseDaoImpl;
import com.qqtech.qquan.order.model.OrderItem;
import com.qqtech.qquan.order.model.OrderItemQuery;
import com.qqtech.qquan.order.model.OrderItemVo;

@Repository
public class OrderItemDaoImpl extends BaseDaoImpl<OrderItem> implements OrderItemDao {
	public static final Logger log = LoggerFactory.getLogger(OrderItemDaoImpl.class);

	@Override
	public Page<OrderItemVo> queryPageList4Admin(OrderItemQuery query, Pageable pageable) {
		List<OrderItemVo> contentList = sqlSessionTemplate.selectList(getSqlName("select4Admin"), getParams(query, pageable));
		int count = sqlSessionTemplate.selectOne(getSqlName("selectCount4Admin"), BeanUtil.toMap(query));
		return new PageImpl<OrderItemVo>(contentList, pageable, count);
	}
	
	@Override
	public List<OrderItemVo> queryList4Admin(OrderItemQuery query, Pageable pageable) {
		return sqlSessionTemplate.selectList(getSqlName("select4Admin"), getParams(query, pageable));
	}
	
	@Override
	public int queryCount4Admin(OrderItemQuery query) {
		return sqlSessionTemplate.selectOne(getSqlName("selectCount4Admin"), BeanUtil.toMap(query));
	}
}
